package com.wthink.hzgj.settings.viewmodel

import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Build
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wthink.hzgj.BusApplication
import com.wthink.hzgj.data.Result
import com.wthink.hzgj.data.domain.BusConfig
import com.wthink.hzgj.data.domain.DevState
import com.wthink.hzgj.data.domain.DeviceVersion
import com.wthink.hzgj.data.domain.DeviceVol

import com.wthink.hzgj.service.DevService

import kotlinx.coroutines.Dispatchers

import kotlinx.coroutines.launch

class SettingsViewModel : ViewModel() {

    val vol = MutableLiveData(DeviceVol(0, 1,1))

    fun setVol(inVol: Int,out:Int,mic:Int){
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.setVol(inVol, out, mic)
        }
    }

    fun getDevVol(type:String){
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.getDevVol(type)
            if (ret is Result.Success) {
                vol.postValue(ret.data)
            }
        }
    }

    fun getbusconfig(type: String){
        viewModelScope.launch(Dispatchers.IO) {
            val ret = DevService.getBusConfig(type)
        }
    }
}
